function doViewSup(id)
{
	ajax.send('?m=suppliers&a=view&suppressHeaders=1&sup_id='+id, '',
		function (r) {
			var cd = Control('idSupDialog').create('div', 'popup', 'hidden');
			cd.innerHTML = r;
			Dialog(cd).show();
		}
	);
}

function doEditSup(id, extra)
{
	ajax.send('?m=suppliers&a=edit&suppressHeaders=1&sup_id='+id+''+extra, '',
		function (r) {
			var cd = Control('idSupDialog').create('div', 'popup', 'hidden');
			cd.innerHTML = r;
			Dialog(cd, 1).show();
			eval($('validation_rules').innerHTML);
		}
	);
}

function doCloseSup()
{
	Dialog('idSupDialog').hide();
}
/* not user
function doChangeDivision()
{
	$('idSupCostCenterName').value = '';
	$('idSupCostCenterId').value = 0;
}
*/
function doShowCostCenterSelector()
{
	//var c = $('idSupDivisionId');
	//var id = c.options[c.selectedIndex].value;
	var id = 0; // select all
	ajax.send('index.php?m=public&a=viewinfo&suppressHeaders=1&type=CostCenterList&id='+id, '',
		function(r) {
			var d = Control('idCostCentertSelector').create('div', 'topper', 'hidden');
			var error = r.indexOf('idCostCenterList') < 0;
			if (!error) {
				r = r.replace(/\n|\r/g,'');
				r = r.replace(/\<tr\>.*?\<\/tr\>/i,'');
				r = r.replace(/width="250px"/i, 'width="260px"');
				r = r.replace(/cellpadding="4"/i, 'cellpadding="0"');
			}
			d.innerHTML = r;
			Control(d).show();
			if (!error) initTree($('idCostCenterTree'));
			$('idSupDialog').onclick = function() {
				Control('idCostCentertSelector').destroy();
				this.onclick = undefined;
			}
			if (error) {
				Control(d).center();
			}
			else {
				var p = Control('idSupCostCenterName').position();
				Control(d).move(p.x + 3, p.y + 22);
			}
		}
	);
}
function doSelectCostCenter(id)
{
	$('idSupCostCenterId').value = id;
	$('idSupCostCenterName').value = unescape($('idCostCenterId['+id+']').getAttribute('value'));
	Control('idCostCentertSelector').destroy();
}

function doDelete(id, name)	{
	if (confirm( "Do you want to delete "+ name)) {
		$('del_cc_id').value = id;
		f = $('MdFormDelete');
		f.del.value = id;
		f.submit();
	}
}
/*
function doChangeCosCenter()
{
	$('idResourceName').value = '';
	$('idResourceId').value = 0;
}
*/